package com.lg.study.stream;

import lombok.AllArgsConstructor;
import lombok.Data;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * @author lg
 * @date 2021/4/18
 */
public class StreamTest {
    public static void main(String[] args) {
        List<Integer> nums = new ArrayList<>();
        nums.add(3);
        nums.add(13);
        nums.add(33);
        nums.add(23);

        List<Integer> res = nums
                .stream()
                .filter(n->n>10)
                .sorted()
                .limit(2)
                .collect(
                        ArrayList::new,
                        ArrayList::add,
                        ArrayList::addAll
                );

        System.out.println(res.toString());
    }

}

@Data
@AllArgsConstructor
class Person {

    private String name;

    private Integer age;
}
